package com.bomb.voice.net.request;

import com.bomb.voice.backNet.AddAccountBean;
import com.bomb.voice.bean.QrCodeBean;
import com.bomb.voice.net.RetrofitServiceManager;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by zhouwei on 16/11/10.
 */

public class VoiceLoader {
    private VoiceBackGroundApi mMovieService;

    public VoiceLoader() {
        mMovieService = RetrofitServiceManager.getInstance().create(VoiceBackGroundApi.class);
    }


    public Observable<AddAccountBean> addAccount( String appAccountId) {
        return mMovieService.addAccount( appAccountId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<QrCodeBean> preRecharge( String appAccountId,float totalAmount) {
        return mMovieService.preRecharge(appAccountId, totalAmount)
                .subscribeOn(Schedulers.io())
//                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<AddAccountBean> disableAccount(String appId, String appAccountId, long ti, String ver, String au) {
        return mMovieService.disableAccount(appId, appAccountId, ti, ver, au)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<AddAccountBean> enableAccount(String appId, String appAccountId, long ti, String ver, String au) {
        return mMovieService.enableAccount(appId, appAccountId, ti, ver, au)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<AddAccountBean> getAccount(String appId, String infoType, String info, long ti, String ver, String au) {
        return mMovieService.getAccount(appId, infoType, info, ti, ver, au)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public interface VoiceBackGroundApi {

        @FormUrlEncoded
        @POST("AddAccount")
        Observable<AddAccountBean> addAccount( @Field("appAccountId") String appAccountId);

        @FormUrlEncoded
        @POST("PreCreate")
        Observable<QrCodeBean> preRecharge( @Field("username") String appAccountId, @Field("totalAmount") float totalAmount);

        @FormUrlEncoded
        @POST("disableAccount")
        Observable<AddAccountBean> disableAccount(@Field("appId") String appId, @Field("appAccountId") String appAccountId, @Field("ti") long ti, @Field("ver") String ver, @Field("au") String au);

        @FormUrlEncoded
        @POST("enableAccount")
        Observable<AddAccountBean> enableAccount(@Field("appId") String appId, @Field("appAccountId") String appAccountId, @Field("ti") long ti, @Field("ver") String ver, @Field("au") String au);

        @FormUrlEncoded
        @POST("getAccount")
        Observable<AddAccountBean> getAccount(@Field("appId") String appId, @Field("infoType") String infoType, @Field("info") String info, @Field("ti") long ti, @Field("ver") String ver, @Field("au") String au);
//infoType	String	是	查询信息类型：1）飞语云账户号码；2）APP账户号码；3）手机号码
        //info	String	是	infoType对应的查询信息
    }
}
